package fun.coding.array;

import java.util.ArrayList;
import java.util.List;

public class RemoveNegativeFromArray {

	public static void main(String[] args) {
		
		List<Integer> al = new ArrayList<Integer>();
		al.add(5);
		al.add(6);
		al.add(-3);
		al.add(6);
		al.add(-2);
		
		print(al);
		
		// This is a very stupid implementation for this issue. ConcurrentModificationException for sure.
		// Wrong solution. 
		for (int i : al) {
			if (i < 0) {
				al.remove((Integer)i);
			}
				
		}
		print(al);
		
		
		System.out.println("Done..");
		
	}
	
	public static void print(List<Integer> al) {
		for (int i : al) {
			System.out.print(i + "\t");
		}
		System.out.println();
	}
	
	// TODO: 
	public static void removeNegativeFromArrayList(List<Integer> al) {
		
	}

}
